# import asyncio
# import time as systime
# from app.utils.decorators import timing_decorator, async_timing_decorator
#
#
# class AsyncService:
#     def __init__(self, name="AsyncSvc"):
#         self.name = name
#
#     @async_timing_decorator
#     async def fetch_user(self, user_id: int):
#         await asyncio.sleep(0.1)  # 模拟异步 I/O
#         return {"id": user_id, "name": "Alice"}
#
#     @classmethod
#     @async_timing_decorator
#     async def create_default(cls):
#         await asyncio.sleep(0.05)
#         return cls("DefaultAsync")
#
#     @staticmethod
#     @async_timing_decorator
#     async def compute(x: int):
#         await asyncio.sleep(0.02)
#         return x ** 2
#
#
# @async_timing_decorator
# async def async_task(n: int):
#     await asyncio.sleep(0.03)
#     return sum(range(n))
#
#
# # 同步函数对比（可选）
# @timing_decorator
# def sync_task():
#     systime.sleep(0.04)
#
#
# async def main():
#     print("🚀 开始异步任务...")
#
#     # 异步实例方法
#     svc = AsyncService()
#     user = await svc.fetch_user(123)
#
#     # 异步类方法
#     svc2 = await AsyncService.create_default()
#
#     # 异步静态方法
#     res = await AsyncService.compute(10)
#
#     # 普通异步函数
#     total = await async_task(1000)
#
#     # 同步函数（对比）
#     sync_result = sync_task()
#
#     print("✅ 所有任务完成")
#     print(f"User: {user}, Total: {total}, Sync: {sync_result}")
#
#
# class DataService:
#     def __init__(self, name="Service"):
#         self.name = name
#
#     @timing_decorator
#     def fetch_data(self, size: int):
#         systime.sleep(0.1)  # 模拟 I/O
#         return list(range(size))
#
#     @classmethod
#     @timing_decorator
#     def create_service(cls, name: str):
#         systime.sleep(0.05)
#         return cls(name=name)
#
#     @staticmethod
#     @timing_decorator
#     def utility_func(x: int):
#         systime.sleep(0.02)
#         return x * 2
#
#
# @timing_decorator
# def standalone_task(n: int):
#     systime.sleep(0.03)
#     return sum(range(n))
#
#
# if __name__ == "__main__":
#     asyncio.run(main())
#
#     print("🚀 启动同步任务...")
#     # 实例方法
#     service = DataService()
#     data = service.fetch_data(100)
#
#     # 类方法
#     svc2 = DataService.create_service("LoggerService")
#
#     # 静态方法
#     res1 = DataService.utility_func(10)
#
#     # 普通函数
#     total = standalone_task(1000)
#
#     print("✅ 所有任务完成")
